row = 351;
col = 726;
% new C, lb,, b
c2=c(1:col);
[cRow cCol] = size(c);
b2 = b(1:row);
lbounds2=lbounds(1:col);

xC = [];
n = 1;
for ii=1:1:row
    if c2(ii) ~= 0
        xC(n,1) = ii;
        n = n + 1;
    end
end

% new A
AT = full(A);
AT2 = AT(1:row,1:col);

lbConstraintA='N';
lbConstraintb='N';
Aeq='N';
beq='N';

tic;

% [nrowAeq, ncolAeq] = size(AT2);
% % check Aeq has full row rank
% if rank(AT2)==nrowAeq
%     fullRowRank=true;
% end
% 
% if fullRowRank   
%     % generate a random integer between 1 and 50
%     gamma = round(rand(1)*49)+1;
%     
%     c2 = gamma * c2;
%     
%     % -----------------------Q, A', b'
%     % generate a m x m non-singular matrix Q (deteminant =/= 0)
%     Q = randi([0,5],nrowAeq);
%     
%     while det(Q)==0
%         Q = randi([0,5],nrowAeq);
%     end
%     
%     AT2 = Q * AT2;                      % A' = QA
%     b2 = Q * b2;                      % b' = Qb
%     
% %     [nrowAeq, ncolAeq] = size(AT2);
% %     % generate a random n x m lambda
% %     Lambda =randi([0,5],ncolAeq,nrowAeq);
% %     
% %     AP = (nA - (Lambda * nAeq));               % B' = (B - LA)
% %     bP = -1 * (Lambda * nbeq); 
% end


xlswrite('BOEING1.xlsx', c2, 'c');
xlswrite('BOEING1.xlsx', AT2, 'A(<=)');
xlswrite('BOEING1.xlsx', b2, 'b(<=)');
xlswrite('BOEING1.xlsx', 'N', 'A(>=)');
xlswrite('BOEING1.xlsx', 'N', 'b(>=)');
xlswrite('BOEING1.xlsx', 'N', 'Aeq(=)');
xlswrite('BOEING1.xlsx', 'N', 'beq(=)');
xlswrite('BOEING1.xlsx', lbounds2, 'lb');
toc

clc;
tic
%   AT = full(A);
%  [x3,fval,exitflag] = linprog(c,A,b,[],[],lbounds)
 [x3,fval,exitflag] = linprog(c2,AT2,b2,[],[],lbounds2)
toc

n=1;
nX3=[];
for ii=1:1:cRow
    if n <= length(xC)        
        if ii == xC(n)
                temp = x3(ii);

            nX3{n,1} = ['x' num2str(ii) ' = ' num2str(temp)];
            n = n + 1;
        end
    end
end

nX3;